Hi, I have to add from external system object which has attribute 'description' nothing special so I do:
The aforementioned code worked for all other attributes of the object but the problem is just for this 'description' , so a question raised in my head is that some kind of special attribute? I saw in the manual:
So is description available for all attributes or ?
Dinio - Fri Dec 11 09:56:47 EST 2015 |
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? You cannot create an attribute of name 'Description" since this attribute already exists. It is a system module attribute. Sean |
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? DoorsXLAustralia - Sat Dec 12 00:31:03 EST 2015 You cannot create an attribute of name 'Description" since this attribute already exists. It is a system module attribute. Sean Ok, But how to understand, using DXL, if the attribute is:
|
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? Ok, But how to understand, using DXL, if the attribute is:
bool system (AttrDef)
bool canModify(Module m, string attrName)
bool exists(attribute(string attributeName))
this scenario is not possible
Sean |
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? Dinio - Sat Dec 12 04:09:14 EST 2015 Ok, But how to understand, using DXL, if the attribute is:
whether an attribute exists: depending on what you want to do. Either make a loop over all attributes of a module:
Module myMod = current // or however you talk to your module in your script
string attrName = "Description"
AttrDef theAD ; for theAD in myMod do
{
if theAD.name == attrName then {
// attribute exists. Do what you want
}
}
or look for the attribute directly
AttrDef theAD = find(myMod, attrName)
if !null theAD then {
// the attribute exists
}
System attribute
if theAD.system then {
// is system attribute
}
to check whether you can write to the attribute, there are several ways. This one seems to be the most robust (here: for object attributes).
noError();
// sorry, the next line was wrong. set is only used for copying values from one attribute to another
//set(theObjectIwantToChange.attrName, "the new content"); <- wrong
theObjectIWantToChange.attrName = "the new content"
string errMsg = lastError();
if (!null errMsg) {
// there was a problem, perhaps no access rights
}
Note that this is a check whether you may change the content(!) of the attribute, not the definition. canModify (myMod.attrName) will check whether you can change the attribute definition.
To test whether the attribute has a different name, I suggest to use the first loop (for ad in module) and check whether there is any attribute that has the old name
Hope this helps, |
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? DoorsXLAustralia - Sat Dec 12 06:28:37 EST 2015 Ok, But how to understand, using DXL, if the attribute is:
bool system (AttrDef)
bool canModify(Module m, string attrName)
bool exists(attribute(string attributeName))
this scenario is not possible
Sean You're right. exists() is the better way to test. |
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? Mike.Scharnow - Sat Dec 12 06:46:53 EST 2015 You're right. exists() is the better way to test. Ok, Thanks a lot. But I read somewhere here in the forum for list of attributes which names are different from the DXL name with which they are called. But I can not find ;for example it was like OBject text is caled with mod."text" or smth.
|
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? Mike.Scharnow - Sat Dec 12 06:46:53 EST 2015 You're right. exists() is the better way to test. No, "bool exists(string)" is a worse way to test. You can't specify the module so it only works if you are checking the current module. Use "AttrDef find(Module, string)" and check for !null AttrDef. -Adam |
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? Adamarla - Mon Dec 14 08:38:59 EST 2015 No, "bool exists(string)" is a worse way to test. You can't specify the module so it only works if you are checking the current module. Use "AttrDef find(Module, string)" and check for !null AttrDef. -Adam The code above do not work it is system attribute,I can not check for the description of an attribute is it modifiable? How to fix it?
Why is this happening to me?
|
Re: Is "descripion" attribute has special meaning in Doors 9.5.1.2? Dinio - Tue Dec 15 06:49:03 EST 2015 The code above do not work it is system attribute,I can not check for the description of an attribute is it modifiable? How to fix it?
Why is this happening to me?
I think the "things" you are dealing with are not yet clear.
An Attribute Definition is what you see when you open the dialog "Edit" → "Attributes" in a module editor. It contains the information which attributes will exist for modules and / or objects. When you look at this dialog, you see that every attribute definition has a "Description". 2nd column.
This description (which contains either "System Attribute" for every system attribute or whatever you entered in the dialog "Edit" or "New" when you create your own attributes) is what you change when you ask for (canModify (attrDef.description) or when you do a "modify (attrDef, setDescription)". This is most likely not what you want.
In this list, you see that also there is an attribute definition of the name(!) "Description". This system attribute exits only for module, not for objects. You can change this description in DOORS at "File" → "Module Properties", field "Description:". In DXL you would set this value by Module modChangeIt = current modChangeIt."Description" = "This module contains hardware specifications for the device xx" or string sAttrName = "Description" modChangeIt.sAttrName = "This module has been imported from customer yy" As the attribute "Description" is not available for objects, you cannot say Object objInteresting // the next line will produce the error -R-E- DXL: <Line:3> unknown Object attribute (Description) objInteresting."Description" = "This requirement describes the measurements of the device xx" Instead, you have to think of another name for the attribute, e.g. "Background Information" Then you can create and fill this attribute
string sAttrName = "Background Information"
AttrDef adBackground = find (modChangeIt, sAttrName)
if (null adBackground) {
// create a new attribute definition for objects.
// lookup examples for the creation of attribute definitions in the manual or the forum
}
// now that we know that the attribute exists, try to modify it
Object objInteresting
for objInteresting in entire modChangeIt do {
if (the object stored in objInteresting is of interest to be changed) {
string sContentOfBackgroundInformation = "This requirement has been introduced as a result of Board Meeting No. 23"
noError()
objInteresting.sAttName = sContentOfBackgroundInformation
// or objInteresting."Background Information" = sContentOfBackgroundInformation
string theError = lastError()
if (!null theError) {
print "Warning: Object number " (objInteresting."Absolute Number" "") " could not be modified\n"
}
}
}
|